# Filename: jit-mda-create-primary.sh
# Usage: jit-mda-create-primary.sh <image name> <backup ip> <backup port> <size> <interval>
# Example: jit-mda-create-primary.sh vm01 10.0.0.2 8002 4G 200
#
# Instantiates the primary side of a failover protected VM from a
# .CFG file and a disk volume copied by the previous scripts.

imagename=$1
primaryIP=$2
backupIP=$3
backupPort=$4
size=$5
interval=$6
SCRIPTS_FOLDER=/root/scripts

echo `date +%H:%M:%S` Starting Script $0 $*
$SCRIPTS_FOLDER/jit-mda-extract-snapshot.sh $imagename $size
$SCRIPTS_FOLDER/jit-mda-configure-drbd.sh $imagename $primaryIP $backupIP
$SCRIPTS_FOLDER/jit-mda-install-failover.sh $imagename $primaryIP $backupIP $backupPort $interval
echo `date +%H:%M:%S` Finishing Script $0
exit 0
